using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DAOLayer;
using BUSLayer;

public partial class FormHuyVe : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int loginStatus = Convert.ToInt32(Session["IsLogin"].ToString());
        if (loginStatus == 0)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            if(IsPostBack==false)
                XuatDSVe();
        }
    }
     
    public void XuatDSVe()
    {
        
        /*TaiKhoanBus TKbus = new TaiKhoanBus();
        KhachHangBus KHBus = new KhachHangBus();
        int MaTK = TKbus.LayMaTK(un, pw);
        int MaKH = KHBus.LayMaKH(MaTK);*/

        int MaKH = int.Parse(Session["MaKH"].ToString());
        VeBus veControl = new VeBus();
        DataTable tbVe = new DataTable();
        tbVe = veControl.DanhSachVe(MaKH);
        DSVeGridView.DataSource = tbVe;
        DSVeGridView.DataBind();
    }

    protected void XoaButton_Click(object sender, EventArgs e)
    {
        /*string un, pw;
        un = Session["UserName"].ToString();
        pw = Session["Password"].ToString();*/

        TaiKhoanBus TKbus = new TaiKhoanBus();
        KhachHangBus KHBus = new KhachHangBus();
        //int MaTK = TKbus.LayMaTK(un, pw);
        int MaKH = int.Parse(Session["MaKH"].ToString());//.ToString();//KHBus.LayMaKH(MaTK);
        DatVeBus dvControl = new DatVeBus();
        //int MaKH = Convert.ToInt32(Session["MaKH"]);
        for (int i = 0; i < DSVeGridView.Rows.Count; i++)
        {
            CheckBox c = (CheckBox)DSVeGridView.Rows[i].FindControl("CheckBox1");
            if (c.Checked == true)
            {
                int MaVe = int.Parse(DSVeGridView.Rows[i].Cells[1].Text);
                dvControl.Xoa(MaVe, MaKH);
            }
        }
        XuatDSVe();
    }
}
